package com.ruoyi.finance.collection.mapper;

import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.finance.collection.domain.vo.ChargeElementsVo;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * @author fuzhen-pc
 * @description TODO
 * @date 2023/7/10 9:09
 */
public interface ChargeElementMapper extends BaseMapper<ChargeElementsVo> {

    //根据项目ID和项目类型查询计费要素
    @DataSource(DataSourceType.SLAVE)
    public List<ChargeElementsVo> selectByProjectIdAndType(@Param("projectId") Long projectId, @Param("projectType") String projectType);

    /**
     * 从UNCONFIRMED_CHARGE_ELEMENTS表中查询计费要素
     * @param projectType
     * @return
     */
    @DataSource(DataSourceType.SLAVE)
    public List<ChargeElementsVo> selectByProjectIdAndTypeFromTable(@Param("projectType") String projectType);

    /**
     * 从V_CHARGE_ELEMENTS_COLLECTION视图中查询计费要素
     * @param projectType
     * @param projectId
     * @return
     */
    @DataSource(DataSourceType.SLAVE)
    public List<ChargeElementsVo> selectByProjectIdAndTypeFromView(@Param("projectType") String projectType, @Param("projectId") Long projectId);

    /**
     * 调用存储过程执行计费要素的查询以及存到UNCONFIRMED_CHARGE_ELEMENTS表的动作
     * @param jsonObject
     */
    public void P_INSERT_CHARGE_ELEMENTS(@Param("jsonObject") JSONObject jsonObject);
    
    // 根据不同的作业类型foreach查询

    /**
     * 根据不同的projectType查询对应子视图获取计费要素
     * @param projectIdList
     * @param projectType
     * @return
     */
    @DataSource(DataSourceType.SLAVE)
    public List<ChargeElementsVo> selectChargeElementsFromTable(@Param("projectIdList") List<Long> projectIdList, @Param("projectType") String projectType);

    /**
     * 批量插入计费要素到UNCONFIRMED_CHARGE_ELEMENTS表
     * @param chargeElementsList
     */
    public void insertChargeElementsBatch(@Param("chargeElementsList") List<ChargeElementsVo> chargeElementsList);

    /**
     * 确认收款后从UNCONFIRMED_CHARGE_ELEMENTS表删除计费要素
     * @param statementId
     */
    public void deleteChargeElements(@Param("statementId") Long statementId);
    
}
